package com.vin.dubbo.examples;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.Method;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * <br>
 *
 * @author levin
 * @version 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/")
public class TestController {

    @DubboReference(methods = {@Method(name = "insertUser", timeout = 1000)})
    private UserService userService;

    @RequestMapping("user")
    public boolean addUser(Long timeout) {
        UserDTO userDTO = new UserDTO();
        userDTO.setAccName(UUID.randomUUID().toString());
        userDTO.setSleep(timeout);
        boolean result = userService.insertUser(userDTO);
        log.info("新增用户{}成功", userDTO.getAccName());
        return result;
    }
}
